<?xml version="1.0"?>
<OnTheFlyInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceId>UploadToDocLIbrary</InstanceId>
  <CustomAppConfig />
  <Tags>
    <string>SharePoint Client</string>
    <string>CSOM</string>
  </Tags>
  <AdditionalAssemblies />
  <Code><![CDATA[// ----------------------
//  Upload Document to a SharePoint document library
// ----------------------
// Resources: 	http://www.sharepoint-reference.com/Blog/Lists/Posts/Post.aspx?ID=29
//				http://sharepoint.stackexchange.com/questions/17026/adding-new-file-in-a-doc-lib-using-client-om-with-contribute-permission-only-fa
using System;
using System.Data;
using System.Linq;
using System.Net;
using xSolon.Instructions.DTO;
using Microsoft.SharePoint.Client;
using xSolon.Instructions;
using xSolon.SP.ManagedClient;

public class SP14Client_Sample : AbstractInstruction
{
	public override void Run()
	{
		var ctx = new SP14ClientHelper().GetContext("http://localhost"
			,SP14AuthenticationType.Windows, this.CredentialCache.First());
	
		var folder = ctx.Web.GetFolderByServerRelativeUrl("/Style Library/XSL Style Sheets/");
		
		var fci = new FileCreationInformation();
		fci.Content = System.IO.File.ReadAllBytes(@"D:\filename.js");
		fci.Url= "fileName.js";
		fci.Overwrite = true;
		
		var file = folder.Files.Add(fci);
		
		var listItem = file.ListItemAllFields;
		ctx.Load(listItem);
		ctx.Load(file);
		
		ctx.ExecuteQuery();
		
		NotifyInformation(file.Name);
	}
	
	
}]]></Code>
</OnTheFlyInstruction>